package artibella.utils 
{
	import flash.geom.Matrix;
	/**
	 * ...
	 * @author pbordachar
	 */
	
	public class GraphicsUtils 
	{
		
		public function GraphicsUtils() 
		{
			throw new Error( "GraphicsUtils : bad use" );
		}
		
		///////  S T A T I C
		
		public static function getGradient( w:int, h:int, colors:Array = null, alphas:Array = null, angle:int = 0 ):Array 
		{
			if ( colors == null ) colors = [ 0, 0xFFFFFF ];
			if ( alphas == null ) alphas = [ .5, 0 ];
			
			var angleR:Number = Math.min( Math.max( ( angle * Math.PI / 180 ), 0 ), Math.PI * .5 );
			
			var gradWidth:Number = w / Math.cos( angleR );
			var gradHeight:Number = h / Math.sin( angleR );
			
			var gradX:Number = ( w - gradWidth ) / 2;
			var gradY:Number = ( h - gradHeight ) / 2;

			var ratios:Array = [ 0, 0xFF ];
			
			var m:Matrix = new Matrix();
			m.createGradientBox( gradWidth, gradHeight, angleR, gradX, gradY );
			
			return [ colors, alphas, ratios, m ];
		}
	}

}